package com.atguigu.rabbit.producer.config;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Taeyang
 */
@Configuration
public class RabbitmqFanoutExchangeConfiguration {

    /**
     * 声明交换机
     */
    @Bean
    public Exchange fanoutExchange() {
        Exchange fanoutExchange = ExchangeBuilder.fanoutExchange("fanout_exchange").durable(true).build();
        return fanoutExchange;
    }

    /**
     * 声明队列
     *
     * @return
     */
    @Bean
    public Queue fanoutQueue01() {
        Queue queue = QueueBuilder.durable("fanout_queue_01").build();
        return queue;
    }

    /**
     * 声明队列
     *
     * @return
     */
    @Bean
    public Queue fanoutQueue02() {
        Queue queue = QueueBuilder.durable("fanout_queue_02").build();
        return queue;
    }

    /**
     * 声明队列和交换机的绑定信息
     */
    @Bean
    public Binding fanoutQueue01Binding() {
        Binding binding = BindingBuilder.bind(fanoutQueue01()).to(fanoutExchange()).with("").noargs();
        return binding;
    }

    /**
     * 声明队列和交换机的绑定信息
     */
    @Bean
    public Binding fanoutQueue02Binding() {
        Binding binding = BindingBuilder.bind(fanoutQueue02()).to(fanoutExchange()).with("").noargs();
        return binding;
    }

}